<template>
  <div>
    <div class="container">
      <div class="handle-box">
        <el-select v-model="query.case_source" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" clearable placeholder="案件来源" class="handle-select mr10">
          <el-option key="1" label="市场查获" value="市场查获"></el-option>
          <el-option key="2" label="投诉举报" value="投诉举报"></el-option>
          <el-option key="3" label="上级交办" value="上级交办"></el-option>
        </el-select>
        <el-select v-model="query.case_type" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" clearable placeholder="案件性质" class="handle-select mr10">
          <el-option key="1" label="一般案件" value="一般案件"></el-option>
          <el-option key="2" label="简易案件" value="简易案件"></el-option>
        </el-select>
        <!--        <el-select v-model="query.tcs_note_id" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" clearable placeholder="证据先行保存通知书状态" class="handle-select mr10">-->
        <!--          <el-option key="1" label="未进行证据先行保存批准书查看及确认" value="证据采集已完成"></el-option>-->
        <!--          <el-option key="2" label="证据先行保存批准书审核中" value="证据先行保存批准书已完成"></el-option>-->
        <!--          <el-option key="3" label="证据先行保存通知书审核已完成" value="证据先行保存通知书审核已完成"></el-option>-->
        <!--          <el-option key="4" label="已完成" value="证据先行保存通知书上传已完成"></el-option>-->
        <!--        </el-select>-->
        <el-input v-model="query.case_number" placeholder="立案编号" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" class="handle-input mr10"></el-input>
        <el-button type="primary" :icon="Search" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)">搜索</el-button>
      </div>
      <el-table :data="tableList" border class="table" ref="multipleTable" header-cell-class-name="table-header">
        <!--        <el-table-column prop="case_id" label="案件号" width="100" align="center"></el-table-column>-->
        <el-table-column prop="case_source" label="案件来源" align="center"></el-table-column>
        <el-table-column prop="case_number" label="立案编号" width="200"  align="center"></el-table-column>
        <el-table-column prop="case_update_time" label="更新时间"  align="center"></el-table-column>
        <el-table-column prop="case_type" label="案件性质" align="center"></el-table-column>
        <el-table-column prop="date_of_filing" label="立案日期"  align="center"></el-table-column>
        <el-table-column label="立案报告表状态" align="center" width="200">
          <template #default="scope">
            <div v-if="scope.row.tcs_note_id === '喷码记录表已完成' ">
              <el-tag :type=" 'danger'">喷码记录表已完成 </el-tag>
            </div>
            <div v-if="scope.row.tcs_note_id === '现场勘验笔录已完成' ">
              <el-tag :type=" 'danger'">现场勘验笔录已完成 </el-tag>
            </div>
            <div v-if="scope.row.tcs_note_id === '立案报告表已完成' ">
              <el-tag :type=" 'warning'">立案报告表主任审核中 </el-tag>
            </div>
            <div v-if="scope.row.tcs_note_id === '立案报告表主任审核已完成' ">
              <el-tag :type=" 'warning'">立案报告表局长审核中 </el-tag>
            </div>
            <div v-if="scope.row.tcs_note_id === '立案报告表审核已完成' ||
            scope.row.tcs_note_id === '卷烟鉴别书已完成' ||
            scope.row.tcs_note_id === '涉案烟草价品核案表完成' ||
            scope.row.tcs_note_id === '询问笔录已完成' ||
            scope.row.tcs_note_id === '已完成' ||
            scope.row.tcs_note_id === '无证经营公示已完成' ||
            scope.row.tcs_note_id ==='卷烟鉴别书已送检'||
            scope.row.tcs_note_id ==='调查终结文书已完成'||
            scope.row.tcs_note_id ==='案件处理审批已开始'||
            scope.row.tcs_note_id ==='集体讨论已开始'||
            scope.row.tcs_note_id ==='集体讨论已完成'||
            scope.row.tcs_note_id ==='听证已开始'||
            scope.row.tcs_note_id ==='听证告知书已完成'||
            scope.row.tcs_note_id ==='听证已完成'||
            scope.row.tcs_note_id ==='案件处理审批已完成'||
            scope.row.tcs_note_id ==='行政处罚事先告知书确认完成'||
            scope.row.tcs_note_id ==='行政处罚事先告知书已完成'||
            scope.row.tcs_note_id ==='行政处罚决定书确认完成'||
            scope.row.tcs_note_id ==='行政处罚决定书已完成'||
            scope.row.tcs_note_id ==='行政罚款收据上传完成'||
            scope.row.tcs_note_id ==='行政罚款收据已完成'||
            scope.row.tcs_note_id ==='结案报告表已完成'||
            scope.row.tcs_note_id ==='撤案集体讨论准备'||
            scope.row.tcs_note_id ==='撤案集体讨论已开始'">
              <el-tag :type=" 'success'">已完成 </el-tag>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="下一步操作" width="300" align="center">
          <template #default="scope">
            <div v-if="scope.row.tcs_note_id === '喷码记录表已完成'||scope.row.tcs_note_id ==='现场勘验笔录已完成'">
              <el-button text :icon="Edit" class="blue" @click="edit_case_report(scope.row)" >
                立案报告表信息查看及确认
              </el-button>
            </div>
            <div v-if="scope.row.tcs_note_id === '立案报告表已完成' ">
              <el-tag :type=" 'warning'">立案报告表主任审核中 </el-tag>
            </div>
            <div v-if="scope.row.tcs_note_id === '立案报告表主任审核已完成' ">
              <el-tag :type=" 'warning'">立案报告表局长审核中 </el-tag>
            </div>
            <div v-if="scope.row.tcs_note_id === '立案报告表审核已完成' ||
            scope.row.tcs_note_id === '卷烟鉴别书已完成' ||
            scope.row.tcs_note_id === '涉案烟草价品核案表完成' ||
            scope.row.tcs_note_id === '询问笔录已完成' ||
            scope.row.tcs_note_id === '已完成' ||
            scope.row.tcs_note_id === '无证经营公示已完成' ||
            scope.row.tcs_note_id ==='卷烟鉴别书已送检'||
            scope.row.tcs_note_id ==='调查终结文书已完成'||
            scope.row.tcs_note_id ==='案件处理审批已开始'||
            scope.row.tcs_note_id ==='集体讨论已开始'||
            scope.row.tcs_note_id ==='集体讨论已完成'||
            scope.row.tcs_note_id ==='听证已开始'||
            scope.row.tcs_note_id ==='听证告知书已完成'||
            scope.row.tcs_note_id ==='听证已完成'||
            scope.row.tcs_note_id ==='案件处理审批已完成'||
            scope.row.tcs_note_id ==='行政处罚事先告知书确认完成'||
            scope.row.tcs_note_id ==='行政处罚事先告知书已完成'||
            scope.row.tcs_note_id ==='行政处罚决定书确认完成'||
            scope.row.tcs_note_id ==='行政处罚决定书已完成'||
            scope.row.tcs_note_id ==='行政罚款收据上传完成'||
            scope.row.tcs_note_id ==='行政罚款收据已完成'||
            scope.row.tcs_note_id ==='结案报告表已完成'||
            scope.row.tcs_note_id ==='撤案集体讨论准备'||
            scope.row.tcs_note_id ==='撤案集体讨论已开始'">
              <el-button text :icon="Edit" class="blue" @click="views_case_report_data(scope.row)" >
                查看立案报告表
              </el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination">
        <el-pagination
            background
            layout="total, prev, pager, next"
            :current-page="query.pageIndex"
            :page-size="query.pageSize"
            :total="pageTotal"
            @current-change="handlePageChange"
        ></el-pagination>
      </div>
    </div>


    <el-dialog title="立案报告表信息修改及确认" v-model="Edit_report_Visible" width="34%">
      <el-form label-width="140px">
        <el-form-item label="商户烟草售卖许可证" >
          <el-select v-model="case_report_data.mer_id"
                     clearable filterable placeholder="请选择" >
            <el-option
                v-for="item in mer_Data"
                :key="item.mer_id"
                :label="item.retail_licence_code"
                :value="item.mer_id"
            >{{item.retail_licence_code}}({{item.mer_name}})</el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="立案时间" >
          <el-date-picker v-model="case_report_data.date_of_filing" type="datetime" placeholder="选择案发日期" value-format="YYYY-MM-DD HH:mm:ss">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="涉案烟草种类数目" >
          <el-input v-model="case_report_data.tce_type_number" disabled ></el-input>
        </el-form-item>
        <el-form-item label="涉案烟草总数" >
          <el-input v-model="case_report_data.tce_number" disabled ></el-input>
        </el-form-item>
        <el-form-item label="案件来源" >
          <el-select  v-model="case_report_data.case_source" clearable filterable placeholder="请选择案件来源">
            <el-option key="1" label="市场查获" value="市场查获"></el-option>
            <el-option key="2" label="投诉举报" value="投诉举报"></el-option>
            <el-option key="3" label="上级交办" value="上级交办"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="当事人姓名" >
          <el-input v-model="case_report_data.tir_person"  ></el-input>
        </el-form-item>
        <el-form-item label="当事人身份证号" >
          <el-input v-model="case_report_data.tir_id_number"  ></el-input>
        </el-form-item>
      </el-form>
      <el-table :data="illeg_evi_Data" border class="table" ref="multipleTable" header-cell-class-name="table-header" >
        <el-table-column prop="evi_id_number" label="证据先行保存通知书编号" align="center"></el-table-column>
        <el-table-column prop="tlc_id" label="案 由"  align="center">
          <template #default="scope">
            <el-select v-model="scope.row.tlc_id"
                       clearable filterable placeholder="请选择涉嫌案由"  @change="edit_illegal(case_report_data.case_id,scope.row.evi_id_number,scope.row.tlc_id)">
              <el-option
                  v-for="item in illegal_Data"
                  :key="item.tlc_id"
                  :label="item.illegal_behavior"
                  :value="item.tlc_id"
              >案由：{{item.illegal_behavior}} 级别：{{item.grade}}
              </el-option>
            </el-select>
          </template>
        </el-table-column>
      </el-table>
      <el-table :data="evidence_ciga_Data" border class="table" ref="multipleTable" header-cell-class-name="table-header">
        <el-table-column prop="ciga_variety" label="烟草种类"  align="center"></el-table-column>
        <el-table-column prop="ciga_model" label="烟草规格"  align="center"></el-table-column>
        <el-table-column prop="evi_number" label="烟草数量"  align="center"></el-table-column>
        <el-table-column prop="inkjet" label="烟草喷码"  align="center"></el-table-column>
        <el-table-column prop="evi_id_number" label="证据先行保存通知书编号"  align="center"></el-table-column>
      </el-table>
      <template #footer>
				<span class="dialog-footer">
					<el-button @click="Edit_report_Visible = false">取 消</el-button>
          <el-button type="primary" @click="views_case_report_data_preview">预 览</el-button>
					<el-button type="primary" @click="edit_case_report_data">修 改</el-button>
          <el-button type="success" @click="certern_case_report">审 核</el-button>
				</span>
      </template>
    </el-dialog>

    <!--    //查看证据立案报告表-->
    <el-dialog title="" v-model="View_report_Visible" width="34%">
      <html>
      <head>
        <title>立案报告表</title>
      </head>
      <body>
      <h1 align="center">
        福建省闽侯县烟草专卖局
      </h1>
      <h2 align="center">
        立案报告表
      </h2>
      <h3 align="center">
        侯烟立【<b><u>{{case_report_data.year}}</u></b>】第<b><u>{{case_report_data.case_number}}</u></b>号
      </h3>

      <table border="1" style="border-collapse: collapse;" width="100%">
        <tr>
          <th colspan="1" width="25%">案由</th>
          <th colspan="3">{{case_report_data.illegal_behavior_data}}</th>
        </tr>
        <tr>
          <th>案件来源</th>
          <th colspan="3">{{case_report_data.case_source}}</th>
        </tr>
        <tr>
          <th>发案时间</th>
          <th>{{case_report_data.year}}年{{case_report_data.month}}月{{case_report_data.day}}日
            {{case_report_data.hour}}时{{case_report_data.min}}分
          </th>
          <th>发案地点</th>
          <th>{{case_report_data.mer_address}}</th>
        </tr>
        <tr>
          <th>当事人</th>
          <th>{{case_report_data.tir_person}}</th>
          <th>证件类型及号码</th>
          <th>许可证号：{{case_report_data.retail_licence_code}}<br>
              身份证：{{case_report_data.tir_id_number}}
          </th>
        </tr>
        <tr>
          <th>住址</th>
          <th colspan="3">{{case_report_data.mer_hometown}}</th>
        </tr>
        <tr>
          <th>案情摘要</th>
          <th colspan="3" align="left">{{case_report_data.year}}年{{case_report_data.month}}月{{case_report_data.day}}日
            {{case_report_data.hour}}时，我局专卖执法人员在闽侯县{{ case_report_data.area_name }}进行{{ case_report_data.case_source }}，
            检查至{{ case_report_data.mer_address }}，依法对闽侯县{{ case_report_data.area_name }}{{ case_report_data.mer_name }}的当事人
            {{ case_report_data.tir_person }}出示执法检查证件表明身份后，
            依法对该店铺进行检查，在该店卷烟柜台内发现一批未印有“由中国烟草总公司专卖”字样的外国卷烟，品种数量如下:
            {{case_report_data.ciga_data}}
            总计{{ case_report_data.tce_type_number_chinese }}品种{{ case_report_data.tce_number_chinese }}
            （具体品种详见先行登记保存通知书,单号{{case_report_data.evi_data}}）。
            由于当事人无法提供购买该批卷烟的合法有效证明，涉嫌 {{case_report_data.illegal_behavior_data}}的行为。为了保全证据，我局专卖执法人员对现场执法情况拍照留证，
            经本局领导批准同意，我局专卖执法人员依法对上述卷烟予以先行登记保存，同时制作检查（勘验）笔录，交当事人{{case_report_data.tir_person}}核对无异议后签字确认。</th>
        </tr>
        <tr>
          <th>承办人意见</th>
          <th colspan="3" align="left">当事人的行为涉嫌违反了{{case_report_data.violate_law}}的规定。根据《烟草专卖行政处罚程序规定》第十六条第（一）项的规定，建议立案调查，进一步查清案件事实。<br><br>
            签名：&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;日期：&emsp;年&emsp;月&emsp;日<br><br></th>
        </tr>
        <tr>
          <th>承办部门意见</th>
          <th colspan="3" align="left"><br><br>
            签名：&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;日期：&emsp;年&emsp;月&emsp;日<br><br></th>
        </tr>
        <tr>
          <th>领导意见</th>
          <th colspan="3" align="left"><br><br>
            签名：&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;日期：&emsp;年&emsp;月&emsp;日<br><br><br></th>
        </tr>
      </table>
      </body>
      </html>
      <template #footer>
				<span class="dialog-footer">
					<el-button @click="View_report_Visible = false">取 消</el-button>
          <el-button type="primary" @click="create_report_word">打 印</el-button>
				</span>
      </template>
    </el-dialog>



  </div>
</template>

<script setup lang="ts" name="basetable">
import { ref, reactive } from 'vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import { Delete, Edit, Search, Plus } from '@element-plus/icons-vue';
import {
  case_evi_Create,
  case_evi_Views,
  case_legal_Create,
  ciga_evudence_Create,
  end_record_data,
  evi_Views,
  fetchData_case,
  fetchData_case_Create,
  fetchData_case_update,
  fetchData_legal_clause,
  fetchData_mer,
  fetchData_s_mongodb_evidence_Cre,
  fetchData_s_mongodb_evidence_Views,
  fetchData_tobacco,
  fetchData_user,
  illegal_record_data,
  illegal_record_Search,
  mer_Create,
  mer_search_api,
  review_price_data,
  staff_evidence_create,
  staff_evidence_data,
  end_record_show,
  record_inquiry_show,
  record_inquiry_print,
  case_evidence_Views, case_evidence_Edit, illegal_record_update, edit_ille_record
} from '../api/index';
import {
  export_word_1, export_word_3,
} from './table_inquiry.vue'

//案件表数据
interface TableItem {
  case_id:number,
  date_of_filing:string,
  date_of_closing:string,
  date_of_archive:string,
  case_source:string,
  case_number:string,
  archive_person:string,
  case_update_time:string,
  ase_type:string,
  case_remark:string,
  tcs_note_id:string,
  ciga_flag:string,
  ciga_num_flag:string,
  mer_flag:string,
}

//获取商户数据用作选项框
interface mer_data {
  mer_id: number,
  mer_format: string,
  mer_address: string,
  mer_person: string,
  mer_record: string,
  date_of_record: string,
  date_of_effect: string,
  date_of_issue: string,
  mer_hometown: string,
  mer_id_number: string,
  mer_tel: string,
  business_licence_code: string,
  licence_state: string,
  storage_address: string,
  retail_licence_code: string,
  category: string,
  area_id: number,
  mer_zip_code: number,
  mer_name: string,
}
const mer_Data = ref<mer_data[]>([]);
const get_mer_opinion = (mer_name:string='',licence_state:string='',mer_person:string='' ,mer_id:number,business_licence_code:string='') =>{
  fetchData_mer(mer_name,licence_state,mer_person,mer_id,business_licence_code).then(res =>{
    mer_Data.value = res.data.data;
  })
}
get_mer_opinion();
//获取执法人员数据作为选择框
interface staff_data{
  staff_id:number,
  staff_name:string,
  staff_gender:string,
  staff_birthday:string,
  staff_ethnicity:string,
  staff_edu_bg:string,
  staff_email:string,
  field_staff_identity_card:string,
  staff_hometown:string,
  staff_degree:string,
  staff_political_status:string,
  staff_post:string,
  staff_account_no:string,
  staff_account_pwd:string,
  staff_starting_time:string,
  staff_authorized:string,
  staff_phone:string,
  staff_tel:string,
  staff_e_sign:string,
  staff_small_number:string,
  staff_license_no:string,
  staff_now_work_degree:string,
  staff_now_evaluate_degree:string,
}
const staff_Data = ref<staff_data[]>([]);
const get_staff_opinion1 = () =>{
  fetchData_user('','','').then(res=>{
    staff_Data.value = res.data.data;
  })
}
get_staff_opinion1();

//获取案由信息数据用作选项框
interface illegal_data {
  tlc_id:number,
  illegal_behavior:string,
  standard:string,
  penalty_range:string,
  statutory_penalty:string,
  grade:string,
  remark:string,
}
const illegal_Data = ref<illegal_data[]>([]);
const get_legal_clause_opinion = (illegal_behavior:string='',standard:string='' ,grade:string='',tlc_id:number) =>{
  fetchData_legal_clause(illegal_behavior, standard,grade,tlc_id).then(res =>{
    illegal_Data.value = res.data.data;
  })
}
get_legal_clause_opinion();


//视图/
const Edit_report_Visible = ref(false);                               //修改立案报告书视图
const View_report_Visible = ref(false);                               //查看立案报告书视图

//通过案件号查询所有证据先行保存通知书
interface Evidence_case_data {
  case_id:number,//案件号
  evi_id_number:string,
  evi_number:number,
  tce_time_year:string,//案件时间
  tce_time_month:string,
  tce_time_day:string,
  tce_type_number:string,
  tce_number:string,
  tce_amount:number,
  tce_remark:string,
  tce_address:string,
}
const evidence_case_Data= ref<Evidence_case_data[]>([]);
const get_evidence_case_Data = (case_id:number) =>{
  case_evi_Views("" ,case_id).then(res=>{
    evidence_case_Data.value = res.data.data;
  })
}

//打印立案报告书
const create_report_word = () =>{
  illegal_record_data(case_report_data.case_id).then(res=>{
    export_word_3(
        res.data.data.year,
        res.data.data.case_number,
        res.data.data.list1,
        res.data.data.case_source,
        res.data.data.month,
        res.data.data.day,
        res.data.data.hour,
        res.data.data.min,
        res.data.data.mer_address,
        res.data.data.tir_person,
        res.data.data.retail_licence_code,
        res.data.data.tir_id_number,
        res.data.data.mer_hometown,
        res.data.data.area_name,
        res.data.data.mer_name,
        res.data.data.list2,
        res.data.data.tce_type_number_chinese,
        res.data.data.tce_number_chinese,
        res.data.data.list3,
        res.data.data.violate_law,
    )
  })
}


interface Evidence_ciga_data {
  case_id:number,
  evi_number:number,
  ciga_variety:string,
  barcode:string,
  ciga_model:string,
  ciga_price:number,
  inkjet:string,
  evi_id_number:string,
}
const evidence_ciga_Data= ref<Evidence_ciga_data[]>([]);
// 暂存立案报告表数据
const case_report_data = reactive({
  year:'',
  month:'',
  day:'',
  hour:'',
  min:'',
  tcs_note:'',
  case_id:0,
  case_source:'',
  case_number:'',
  date_of_filing:'',
  mer_address:'',
  mer_person:'',
  mer_id_number:'',
  mer_hometown:'',
  mer_name:'',
  retail_licence_code:'',
  area_name:'',
  tce_type_number:'',
  tce_number:'',
  tce_type_number_chinese:'',
  tce_number_chinese:'',
  mer_id:'',
  tir_id_number:'',
  tir_person:'',
  list1:[],
  list2:[],
  list3:[],
  illegal_behavior_data : '',
  ciga_data : '',
  evi_data : '',
  violate_law:'',
})
//先行保存通知书与案由对应表
interface Illeg_evi_data {
  evi_id_number:string,
  tlc_id:number,
}
const illeg_evi_Data = ref<Illeg_evi_data[]>([]);
//获取立案报告表中的数据
const get_case_report_data= (row:any) =>{
  case_report_data.case_id = row.case_id
  illegal_record_data(row.case_id).then(res=>{
        case_report_data.year= res.data.data.year;
        case_report_data.month = res.data.data.month;
        case_report_data.day = res.data.data.day;
        case_report_data.hour = res.data.data.hour;
        case_report_data.min = res.data.data.min;
        case_report_data.case_source = res.data.data.case_source;
        case_report_data.case_number = res.data.data.case_number
        case_report_data.date_of_filing = res.data.data.date_of_filing
        case_report_data.mer_address = res.data.data.mer_address
        case_report_data.mer_person = res.data.data.mer_person
        case_report_data.mer_id = res.data.data.mer_id
        case_report_data.mer_id_number = res.data.data.mer_id_number
        case_report_data.mer_hometown = res.data.data.mer_hometown
        case_report_data.mer_name = res.data.data.mer_name
        case_report_data.mer_person = res.data.data.mer_person
        case_report_data.retail_licence_code = res.data.data.retail_licence_code
        case_report_data.tce_type_number = res.data.data.tce_type_number
        case_report_data.tce_number = res.data.data.tce_number
        case_report_data.tce_type_number_chinese = res.data.data.tce_type_number_chinese
        case_report_data.tce_number_chinese = res.data.data.tce_number_chinese
        case_report_data.tir_person = res.data.data.tir_person
        case_report_data.tir_id_number = res.data.data.tir_id_number
        case_report_data.violate_law=res.data.data.violate_law
        case_report_data.list1 = res.data.data.list1
        case_report_data.list2 = res.data.data.list2
        case_report_data.list3 = res.data.data.list3
        evidence_ciga_Data.value = res.data.data.list2
        illeg_evi_Data.value = res.data.data.list3
        res.data.data.list1.forEach(function (item) {
          case_report_data.illegal_behavior_data = case_report_data.illegal_behavior_data + item.illegal_behavior + '、'
        })
        res.data.data.list2.forEach(function (item) {
          case_report_data.ciga_data = case_report_data.ciga_data + '“' + item.ciga_model + ' ' + item.ciga_variety +
              '“'+item.evi_number+'条，'
        })
        res.data.data.list3.forEach(function (item) {
          case_report_data.evi_data = case_report_data.evi_data + '侯烟存通字【'+ case_report_data.year +'】第'+
              item.evi_id_number + '号、'
        })
      }
  )
}
//修改立案报告表中的信息
const edit_case_report_data = () =>{
  illegal_record_update(case_report_data.case_id,case_report_data.mer_id,case_report_data.date_of_filing,
      case_report_data.case_source,case_report_data.tir_person,case_report_data.tir_id_number,case_report_data.case_number).then(res=>{
    if (res.data.message === "success"){
      ElMessage.success('修改成功');

    }else {
      ElMessageBox.confirm('修改失败', '提示', {
        type: 'warning'
      })
    }
  })
}
//完成立案报告表
const certern_case_report = () =>{
  case_report_data.tcs_note = "立案报告表已完成"
  fetchData_case_update(case_report_data.case_id,case_report_data.tcs_note).then(res=>{
    if (res.data.message === "success"){
      ElMessage.success('立案报告表已完成');
      getData();
      Edit_report_Visible.value = false;
    }else {
      ElMessageBox.confirm('状态更新失败', '提示', {
        type: 'warning'
      })
    }
  })

}
const views_case_report_data_preview = () =>{
  View_report_Visible.value = true;
}
const edit_illegal =(case_id:number,evi_id_number:string='',tlc_id:number)=>{
  edit_ille_record(case_id,evi_id_number,tlc_id).then(res=>{
    if (res.data.message === "success"){
      ElMessage.success('修改成功');
    }else {
      ElMessageBox.confirm('修改失败', '提示', {
        type: 'warning'
      })
    }
  })
}




//列表中的按钮
//修改立案报告表
const edit_case_report = (row:any) =>{
  case_report_data.case_id = row.case_id
  get_case_report_data(row);
  Edit_report_Visible.value = true;
}
//查看立案报告表视图
const views_case_report_data = (row:any) =>{
  case_report_data.illegal_behavior_data=""
  case_report_data.ciga_data=""
  case_report_data.evi_data=""
  case_report_data.case_id = row.case_id
  get_case_report_data(row);
  View_report_Visible.value = true;
}


const query = reactive({
  case_source:'',
  case_type:'',
  tcs_note_id:'',
  case_number:'',
  pageIndex: 1,
  pageSize: 10
});
const tableData = ref<TableItem[]>([]);
const tableList = ref<TableItem[]>([]); // 用于存放分页数据的列表
const pageTotal = ref(0);
const name = localStorage.getItem('ms_username');
// 获取表格数据
const getData = (archive_person:string='',case_id:number,case_source:string='',case_type:string='',case_number:string='',tcs_note_id:string='',name:string='') => {
  fetchData_case(archive_person,case_id,case_source,case_type,case_number,tcs_note_id,name).then(res => {
    tableData.value = res.data.data.filter((i: { tcs_note_id: string; }) =>(
            i.tcs_note_id =="喷码记录表已完成" ||
            i.tcs_note_id =="立案报告表已完成" ||
            i.tcs_note_id =="立案报告表审核已完成" ||
            i.tcs_note_id =="卷烟鉴别书已完成" ||
            i.tcs_note_id =="涉案烟草价品核案表完成" ||
            i.tcs_note_id =="询问笔录已完成" ||
            i.tcs_note_id =="无证经营公示已完成" ||
            i.tcs_note_id =="立案报告表主任审核已完成"||
            i.tcs_note_id=="现场勘验笔录已完成"||
            i.tcs_note_id=="卷烟鉴别书已送检"||
            i.tcs_note_id=="调查终结文书已完成"||
            i.tcs_note_id=="案件处理审批已开始"||
            i.tcs_note_id=="集体讨论已开始"||
            i.tcs_note_id=="集体讨论已完成"||
            i.tcs_note_id=="听证已开始"||
            i.tcs_note_id=="听证告知书已完成"||
            i.tcs_note_id=="听证已完成"||
            i.tcs_note_id=="案件处理审批已完成"||
            i.tcs_note_id=="行政处罚事先告知书确认完成"||
            i.tcs_note_id=="行政处罚事先告知书已完成"||
            i.tcs_note_id=="行政处罚决定书确认完成"||
            i.tcs_note_id=="行政处罚决定书已完成"||
            i.tcs_note_id=="行政罚款收据上传完成"||
            i.tcs_note_id=="行政罚款收据已完成"||
            i.tcs_note_id=="结案报告表已完成"||
            i.tcs_note_id=="已完成"||
            i.tcs_note_id=="撤案集体讨论准备"||
            i.tcs_note_id=="撤案集体讨论已开始"
    )  )
    tableList.value = [];
    pageTotal.value = tableData.value.length || 50;
    // 根据页码确定下标位置
    const index: number = query.pageIndex * query.pageSize - query.pageSize;
    for (let i = index; i < index + query.pageSize; i++) {
      // 防止数组下标越界
      if (i <= tableData.value.length - 1) {
        tableList.value.push(tableData.value[i])
      } else {
        // 越界就不再循环
        break;
      }
    }
  });
};
getData('','','','','','',localStorage.getItem('ms_username'));
// 查询操作
const handleSearch = (case_number:string='',tcs_note_id:string='',case_source:string='',case_type:string='') => {
  getData('','',case_source,case_type,case_number,tcs_note_id,name);
};
// 分页导航
const handlePageChange = (val: number) => {
  query.pageIndex = val;
  getData('','','','','','',localStorage.getItem('ms_username'));
};
</script>

<style scoped>
.handle-box {
  margin-bottom: 20px;
}

/*:deep .el-select-dropdown{*/
/*  max-width: 243px;*/
/*}*/
/*:deep .el-select-dropdown__item{*/
/*  display: inline-block;*/
/*}*/
/*.el-select-dropdown__item span {*/
/*  min-width: 205px;*/
/*  display: inline-block;*/
/*}*/


.handle-select {
  width: 120px;
}

.handle-input {
  width: 300px;
}
.table {
  width: 100%;
  font-size: 14px;
}
.red {
  color: #ff0000;
}

:deep(.avatar){
  width: 100px;
  height: 100px;
}
.blue {
  color: rgba(0, 118, 252, 0.79);
}
.mr10 {
  margin-right: 10px;
}
.table-td-thumb {
  display: block;
  margin: auto;
  width: 40px;
  height: 40px;
}
.handle-box button{
  background-color: #00a854;
}
/*#inspect_record{*/
/*  position: relative;*/
/*  left: 0px;*/
/*  top: -20px;*/

/*}*/

/*#filing_report_review{*/
/*  position: relative;*/
/*  left: 0px;*/
/*  top: -22px;*/
/*}*/
</style>
